#!/bin/bash

tmpdir=/tmp/myarm-tmp
bitfile=/c/Users/user/Desktop/myarm_vc707_vivado/myarm_vc707_vivado.runs/impl_1/top.bit
data2mem=/e/Xilinx/14.7/ISE_DS/ISE/bin/nt64/data2mem.exe
binfilepath="$1"

set -e
mkdir -p "$tmpdir"
stem=`basename -s .bin "$binfilepath"`
memfilepath="$tmpdir/$stem.mem"
bin/binto mem "$binfilepath" "$memfilepath"
$data2mem -bm blk_ram.bmm -bt "$bitfile" -bd "$memfilepath" -o b "$tmpdir/$stem.bit"
